package com.qf.util;

import lombok.Data;

import java.util.List;
@Data
public class PageInfo<DD> {

    //1.当前页
    private  Integer page;

    //2.每页显示条数
    private Integer size;

    //3.数据的总条数
    private Integer count;

    //4.数据的总页数
    private Integer pages ;

    //5.起始索引
    private  Integer offset;

    //6.具体的数据
    private List<DD> list;

    public PageInfo(Integer page, Integer size, Integer count) {
        this.page = page <1 ? 1 : page;
        this.size = size <1 ? 5 : page;
        this.count = count;
        this.pages = (int) (Math.ceil(this.count * 1.0 / this.size));
        this.offset =(this.page-1) * this.size;
    }


    /**
     * 当前页   每页显示条数     总页数
     * 5         16               4
     * Math.ceil(count / size)
     * offset ->0   ,   5  , 10 , 15
     */

}
